﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;

namespace WorkItemCollaborator
{
    public sealed class HtmlToDocumentConverter : IMultiValueConverter
    {
        #region IMultiValueConverter Members

        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            WebBrowser wb;
            string html;
            if (values.Length == 2
                && (null != (wb = values[0] as WebBrowser))
                && (null != (html = values[1] as string)))
            {
                //navigate to "about: blank" to initialize an empty document
                if (!String.IsNullOrWhiteSpace(html))
                {
                    wb.NavigateToString(html);
                }
            }

            return DependencyProperty.UnsetValue;
        }


        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            // This converter is meant for one way only.
            throw new NotImplementedException("This converter is meant for one way only");
        }

        #endregion
    }
    
}
